package com.coldchain.admin.rpc;

import com.coldchain.admin.resoure.api.MenuController;
import com.coldchain.admin.resoure.service.IMenuService;
import com.coldchain.authclient.annotation.CheckUserToken;
import com.coldchain.common.msg.BaseResponse;
import com.coldchain.common.msg.ObjectRestResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

/**
 * @ClassName MenutRpcController
 * @Description TODO
 * @Author fangliai
 * @Date 2018/9/22 13:07
 * @Vesion 1
**/
@RestController

@CheckUserToken
public class MenutRpcController {
    private static Logger log= LoggerFactory.getLogger(MenuController.class);
    @Autowired
    private IMenuService menuService;
    /**
     * 获取我的菜单
     * @return
     */
    @RequestMapping("/menu/getCurrentUserMenu")
    @ResponseBody
    @CheckUserToken
    @ApiIgnore
    public BaseResponse getCurrentUserMenu(){
        try {
            return  new ObjectRestResponse<>().data(menuService.getCurrentUserMenu());
        }catch (Exception e){
            log.error("加载用户菜单失败error:{}",e.getMessage());
            return  new ObjectRestResponse<>().error();
        }

    }
}
